package com.xymtop.api.config;
import java.lang.reflect.InvocationTargetException;
import java.util.*;

import com.xymtop.api.inspector.Ins;
import org.reflections.Reflections;

public class ServiceLocator {
    /**
    *@Description:获取当前目录下所有审查器的类
    *@Parameter:[]
    *@Return:java.util.Map<java.lang.String,java.lang.Class>
    *@Author:肖叶茂
    *@Date:2022/12/4
    **/
    public static List<String> getAllIPeopleImpl() throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
        Reflections reflection=new Reflections("com.xymtop.api.inspector");
        Set<Class<? extends Ins>> set=reflection.getSubTypesOf(Ins.class);
        List<String> cs =new ArrayList<>();

        for(Class c:set){
            cs.add(c.toString());
//            System.out.println(c.toString());
            c.getClassLoader().loadClass(c.toString()).getDeclaredMethod("startTask").invoke(c.newInstance());
        }
        return cs;
    }

//    public static void main(String[] args) throws ClassNotFoundException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
////        System.out.println(ServiceLocator.getAllIPeopleImpl().values());
//        ServiceLocator.getAllIPeopleImpl();
//    }
}

